'use strict';
module.exports = app => {
  const { STRING, INTEGER, TEXT } = app.Sequelize;
    const Model = app.model.define(
      'condition',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
          option: TEXT,
          category_id: INTEGER(11),
          tag_id: INTEGER(11),
          image_num: INTEGER(11),
          field_key: STRING(255),
          field_name: STRING(255),
          field_type: STRING(255),
          sort: STRING(255),
          status: INTEGER(11),
          filter_flag: INTEGER(11),
      },
      {
          tableName: 'condition',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: 'updated_time', // 不想要 updatedAt
          createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
      }
  );
    Model.associate = function() {
        app.model.Condition.belongsTo(app.model.Category, { foreignKey: 'category_id', targetKey: 'id' });
    }
    return Model;
};
